package jsyf.oa.web.report.theWeather;


import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import jsyf.com.util.BaseUtils;
import jsyf.com.util.ResponseUtils;
import jsyf.oa.facade.report.theWeather.TheWeatherFacade;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by LT on 2018/5/24.
 */
@Api(value = "获取天气", description = "获取天气")
@Controller
@RequestMapping("/theWeather")
public class theWeatherController {
    @Resource
    private TheWeatherFacade theWeatherFacade;

    @ResponseBody
    @RequestMapping(value = "/getTheWeather.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取天气",
            notes = "获取天气",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{lat1:'38.84124647',lng1:'100.82616536',lat2:'38.92687744140625',lng2:'100.46052978515625'}", dataType = "String", paramType = "body")
    public void getTheWeather(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject records = this.theWeatherFacade.getTheWeather(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrHourTimeRespond(records));
    }
}
